Function: morph(stringMarkupOrCSSSelector, boolReturnArray, domContext)
Description: Will transform any markup string, CSS selector, or number object into a returnable DOM node object that supports element.appendChild(), or as an iterable array.
Returns: domElement, or an Array of domElements.
Note: If a dom Node is passed into the first parameter instead of a string or number object, it will be returned without modification. When boolReturnArray is true, an array of DOM nodes will be returned instead. When domContext is set to a DOM node container element, the context element will be queried if the first parameter is a valid CSS selector. Otherwise, domContext will always be set to document when not specified.
Example:
// Transform a markup string into a DOM node.
var myNode = $A.morph('
Stuff here.
');
// Transform a CSS selector into a DOM node.
var myNode = $A.morph("#myElementId");
// Transform a CSS selector into a DOM node or an array of DOM nodes.
// Will return an H2 DOM node if only one is found, otherwise all matches will be returned as an array.
var myObject = $A.morph("h2");
// Transform a CSS selector into a DOM node and return all matching elements in an array.
// Will always return an array, even when no matches are found, or when one match is found.
var myNodes = $A.morph("h1", true);
// Transform a number object into a DOM text node.
var myNode = $A.morph(4 + 3 + 5);
// Transform a text string into a DOM text node.
var myNode = $A.morph("Here we are now, entertain us.");
// View the $A.toNode() help documentation to learn how to convert an array of DOM nodes back into a single document fragment element, available at: "Help/$A API/DOM Elements/ToNode"